<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app;

abstract class Rest extends BaseController
{
    public $_app;
    public $_controller;
    public $_action;
    public $_method = "GET";
    public $_param = [];
    public $_input = [];
    public $_header = [];
    public $_token;
    public $_lang = "zh-cn";
    public $_role = "guest";
    public $_host;
    public $_ip;
    public $_user;
    public $_uniacid = "7777";
    protected $middleware = ["app\\middleware\\CheckInput"];
    public function __construct(\think\App $app)
    {
        dump(1);
        exit;
    }
    public function success($data, $code = 200)
    {
        $result["data"] = $data;
        $result["code"] = $code;
        $result["sign"] = NULL;
        if(!empty($this->_token)) {
            $result["sign"] = createSimpleSign($this->_token, is_string($data) ? $data : json_encode($data));
        }
        return $this->response($result, "json", $code);
    }
    public function error($msg, $code = 400)
    {
        $result["error"] = $msg;
        $result["code"] = $code;
        return $this->response($result, "json", $code);
    }
    protected function response($data, $type = "json", $code = 200)
    {
        return \think\Response::create($data, $type)->code($code);
    }
    public function _empty($method)
    {
        if(method_exists($this, $method . "_" . $this->method . "_" . $this->type)) {
            $fun = $method . "_" . $this->method . "_" . $this->type;
        } elseif($this->method == $this->restDefaultMethod && method_exists($this, $method . "_" . $this->type)) {
            $fun = $method . "_" . $this->type;
        } elseif($this->type == $this->restDefaultType && method_exists($this, $method . "_" . $this->method)) {
            $fun = $method . "_" . $this->method;
        }
        if(isset($fun)) {
            return \think\App::invokeMethod([$this, $fun]);
        }
        throw new \Exception("error action :" . $method);
    }
}

?>